<!doctype html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <div th:replace="includes/common :: header-css"/>
</head>
<body style="padding: 10px;">
<form class="layui-form" th:object="${projectModule}">
    <input type="hidden" name="projectModuleId" th:value="*{projectModuleId}"/>
    <div class="layui-form-item">
        <label class="layui-form-label">模块名</label>
        <div class="layui-input-block">
            <input type="text" name="moduleName" th:value="*{moduleName}" placeholder="请输入模块名" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">展示名</label>
        <div class="layui-input-block">
            <input type="text" name="moduleNameCn" th:value="*{moduleNameCn}" placeholder="请输入展示名" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">MappingUri</label>
        <div class="layui-input-block">
            <input type="text" name="controlMappingUri" th:value="*{controlMappingUri}" placeholder="请输入ControlMappingUri" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="submitProjectModule">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>

<div th:replace="includes/common :: js"></div>
<script>
    layui.use(['form', 'layer'], function(){
        var form = layui.form,
            layer = layui.layer,
            $ = layui.jquery;

        form.on('submit(submitProjectModule)', function(data){
            var index = parent.layer.getFrameIndex(window.name);

            var map = data.field;
            map.projectConfigId = Main.projectConfigId;
            $.post("/api/projectModule", map, function(res) {
                if(res != null && res > 0) {
                    parent.layer.msg('操作成功', {icon: 6});
                    parent.layer.close(index);

                    parent.layui.table.reload("projectModulesTable");
                } else {
                    layer.msg('操作失败', {icon: 5});
                }
            });

            return false;
        });
    });
</script>
</body>
</html>